<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong>{{ farr.length }} </strong></span
    >
    <ul class="filters">
      <li v-for="(item, index) in state" :key="index">
        <a
          :class="{ selected: flag === isSel[index] }"
          @click="AllList(index)"
          href="javascript:;"
          >{{ item }}</a
        >
      </li>
    </ul>
    <button class="clear-completed" @click="remove">清除已完成</button>
  </footer>
</template>

<script>
export default {
  props: ['farr'],
  data() {
    return {
      // 定义一个初始状态
      flag: 'all',
      isSel: ['all', 'no', 'yes'],
      state: ['全部', '未完成', '已完成']
    }
  },
  methods: {
    AllList(i) {
      this.flag = this.isSel[i]
      this.$emit('showFlag', this.isSel[i])
    },
    remove() {
      this.$emit('creatDone')
    }
  }
}
</script>
